package com.quanyan.place.service;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.place.entity.TbBizPlaceOrder;
import com.quanyan.place.entity.TbBizPlaceOrderItem;
import com.quanyan.place.entity.apireq.ReqPlaceTicket;
import com.quanyan.place.entity.apireq.ReqTicketPay;
import com.quanyan.place.entity.apiresp.RespPlaceTicketDetail;
import com.quanyan.place.entity.apiresp.RespPlaceTicketDetailSum;
import com.quanyan.place.wrapper.PlaceOrderServiceWrapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by youxiaojia on 2016/9/21.
 * 场馆门票Service
 */
public interface PlaceTicketService {
    /**
     * 添加门票销售
     * @param reqPlaceTicket
     * @return
     */
    APIResponse insertPlaceTicket(ReqPlaceTicket reqPlaceTicket);

    /**
     * 门票销售列表 , 显示项目名称
     * @param placeId
     * @param categoryId
     * @return
     */
    APIResponse queryPlaceTicketList(Integer placeId, Integer categoryId);

    /**
     * 取消门票销售
     * @param tbPlaceTicketSalePlanId
     * @return
     */
    APIResponse cancelPlaceTicketSale(Integer tbPlaceTicketSalePlanId,Integer uid);

    /**
     * 根据门票id获取门票详情
     * @param tbPlaceTicketSalePlanId
     * @return
     */
    APIResponse getPlaceTicketSaleDetailById(Integer tbPlaceTicketSalePlanId);

    /**
     * 编辑门票
     * @param reqPlaceTicket
     * @return
     */
    APIResponse editPlaceTicketSale(ReqPlaceTicket reqPlaceTicket);

    /**
     * 门票查询会员卡根据手机号
     * @param placeId
     * @param phone
     * @return
     */
    APIResponse queryNumCardList(Integer placeId,String phone);
    
    /**
     * 门票查询会员卡根据手机号、姓名模糊查询
     * @param placeId
     * @param phone
     * @return
     */
    APIResponse querymemberNumCardList(Integer placeId,String phone);

    /**
     * 购买门票
     * @param reqTicketPay
     * @return
     */
    APIResponse ticketPay(ReqTicketPay reqTicketPay) throws Exception;

    /** 扫码购买门票 **/
    APIResponse ticketPayForScanPay(ReqTicketPay reqTicketPay) throws Exception;

    void ticketStatisticsForScanPay(Integer placeId, List<TbBizPlaceOrderItem> tbBizPlaceOrderItems);

    /** 门票退款统计(加库存) **/
    void updateTicketStatistics(TbBizPlaceOrder tbBizPlaceOrder, List<TbBizPlaceOrderItem> tbBizPlaceOrderItems) throws Exception;
    
    /** 门票 部分退款统计(加库存) **/
   void updateTicketStatisticsByPart(TbBizPlaceOrder tbBizPlaceOrder,TbBizPlaceOrderItem tbBizPlaceOrderItem,Integer refundTicketCount) throws Exception;

    /**
     * 门票销售明细报表
     * @param placeId
     * @param startDate
     * @param endDate
     * @param pageNum
     * @param pageSize
     * @return
     */
    APIResponse ticketSaleDetail(Integer placeId,Date startDate,Date endDate,Integer pageNum,Integer pageSize);

    /**
     * 门票销售明细报表导出（不分页）
     * @param placeId
     * @param startDate
     * @param endDate
     * @return
     */
    APIResponse ticketSaleDetailExport(Integer placeId, Date startDate, Date endDate);

    Integer getUidByPhone(String phone);

    /**
     * 异步调用短信发送
     * @param phone
     * @param templateId
     * @param args
     * @param failResend
     */
    void asyncSendSms(String phone, Byte templateId, String[] args, boolean failResend);

    /**
     * 同一手机短信连续发送短信一秒钟不能超过一条
     * @param phone
     * @param phoneCompare
     * @param templateId
     * @param args
     * @param failResend
     */
    void asyncSendSmsToOperator(String phone,String phoneCompare, Byte templateId, String[] args, boolean failResend);

    /**
     * 根据订单号查询门票销售数
     * @param orderNo
     * @return
     */
    Integer getTicketSaleCountByOrderNo(String orderNo);

    /**
     * 门票销售明细
     *
     * @param map
     * @return
     */
    APIResponse<PageObj<RespPlaceTicketDetailSum>> getTicketDetail(@Param("map")Map<String,Object> map);

    /**
     * 门票销售明细导出
     *
     * @param map
     * @return
     */
    APIResponse<RespPlaceTicketDetailSum> getTicketDetailExport(@Param("map")Map<String,Object> map);

    /**
     * 门票销售统计  --按门票编号
     * @param map
     * @return
     */
    APIResponse<?> getTicketStatisticsByTicketCode(@Param("map")Map<String, Object> map);

    /**
     * 门票销售统计  --按门票编号(导出)
     * @param map
     * @return
     */
    APIResponse<?> getTicketStatisticsByTicketCodeExport(@Param("map")Map<String, Object> map);

    /**
     * 门票销售统计  --按销售渠道
     * @param map
     * @return
     */
    APIResponse<?> getTicketStatisticsByOrderChannel(@Param("map")Map<String, Object> map);

    /**
     * 门票销售统计  --按运动类型
     * @param map
     * @return
     */
    APIResponse<?> getTicketStatisticsByCategory(@Param("map")Map<String, Object> map);

    /**
     * 门票销售统计  --按散客门票
     * @param map
     * @return
     */
    APIResponse<?> getTicketStatisticsByMember(@Param("map")Map<String, Object> map);
}
